<template>
  <div class="bg-white rounded-lg p-5 h-full">
    <div class="font-bold text-lg mb-4">机构自查自纠列表</div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item prop="selfExaminationType">
        <el-select v-model="queryParams.selfExaminationReportType" placeholder="报告类型">
          <el-option
            v-for="item in dict.type.self_examination_report_type"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="reportType">
        <el-select v-model="queryParams.reportType" placeholder="自查类型">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb-4">
      <el-button type="primary" @click="search">搜索</el-button>
      <el-button @click="reset">重置</el-button>
    </el-row>
    <el-table border v-loading="loading" :data="dataList">
      <el-table-column type="index" width="55" align="center" label="序号" />
      <el-table-column
        label="医疗机构名称"
        align="center"
        prop="enterpriseName"
      >
      </el-table-column>
      <el-table-column label="报告类型" align="center" prop="reportType" >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.self_examination_report_type"
            :value="scope.row.reportType"
          />
        </template>
        </el-table-column>
      <el-table-column label="自查类型" align="center" prop="selfExaminationType" />
      <el-table-column label="自查项目数" align="center" prop="selfExaminationNum" />
      <el-table-column label="发现问题项目数" align="center" prop="problemNum" />
      <el-table-column label="问题已完成整改数" align="center" prop="rectificationNum" />
      <el-table-column
        label="操作"
        align="center"

        width="350"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="toDetailPage(scope.row)"
            >查看详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <hr class="my-4" />
    <div>
      <el-button type="primary" @click="goBack">返回</el-button>
      <!-- <el-button type="primary" @click="submit">提交</el-button> -->
    </div>
  </div>
</template>

<script>
import { getInspectionListAPI } from "@/api/zhangping/health-care/base-info";
export default {
  dicts:['self_examination_report_type','self_examination_type'],
  mixins: [],
  components: {},
  props: {},
  data() {
    return {
      options: [],
      value: "",
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        selfExaminationType:null,
        reportType:null,
      },
      dataList:[],
      loading:false ,
      total:0
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    // 获取url上的参数
    const creditCode = this.$route.query.creditCode;
    this.queryParams.creditCode = creditCode;
    console.log("=====" +creditCode);
    this.getDataList();
  },
  methods: {
    getDataList() {
      this.loading = true;
      getInspectionListAPI(this.queryParams).then((res) => {
        this.total=res.total;
        this.dataList = res.rows;
      }).finally(()=>{
        this.loading = false;
      })
    },
    toDetailPage(row){
        const obj = {
        path: "/health-care/inspect-detail",
        query: {
          id: row.id,
          report: row.reportType,
          inspect: row.selfExaminationType,
          fill:row.fillPerson,
          review:row.reviewer,
        },
      };
      this.$router.push(obj);
    },
    goBack(){
      this.$router.go(-1);
    },
    submit(){},
    search() {},
    reset() {
      this.$refs.queryForm.resetFields();
      this.search();
    },
  },
};
</script>

<style scoped lang="scss"></style>
